package com.Home.Control;

import com.Home.Dao.GoodsDao;
import com.Home.bean.BaseEnity;
import com.Home.bean.GoodsBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class GoodsController {


    @Autowired
    private GoodsDao goodsDao;

    @RequestMapping(value = "/goods/all")
    public Object findAllGoodsInfo(){

        List<GoodsBean> goodsAll = goodsDao.findAllImg();
        BaseEnity<List<GoodsBean>> enity = new BaseEnity<List<GoodsBean>>();
        if(null == goodsAll || goodsAll.size() == 0){
            System.out.println("空数据");
            enity.setCode(0);
            enity.setMsg("没有查询到");
            enity.setData(null);
        }else{
            System.out.println("不是"+goodsAll.size());
            for(int i=0; i<goodsAll.size(); i++){
//                System.out.println("不是"+goodsAll.get(i).getName());
            }
            enity.setData(goodsAll);
            enity.setMsg("成功获取数据");
            enity.setCode(200);
        }
        return enity;
    }
}
